package com.jake.springboot.order.service;

import com.jake.springboot.order.constant.OrderTypeEnum;
import com.jake.springboot.order.context.StrategyContext;
import com.jake.springboot.order.dto.OrderDTO;
import com.jake.springboot.order.strategy.AbstractStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class CancelOrderStrategyService {

    @Autowired
    private StrategyContext strategyContext;

    public void process(OrderDTO orderDTO) {
        OrderTypeEnum orderTypeEnum = OrderTypeEnum.getByCode(orderDTO.getServiceType());
        AbstractStrategy strategy = strategyContext.getStrategy(orderTypeEnum);
        strategy.process(orderDTO);
    }

}
